tools: ocaml: Handle anonymous struct members of structs in libxl IDL
authorIan Campbell <ian.campbell@citrix.com>
Wed, 8 Jul 2015 14:29:10 +0000 (15:29 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 9 Jul 2015 11:15:39 +0000 (12:15 +0100)
commit7617641fe827f66c24e07d9b1ff54a16565ee675
treede87420be78ca06a7801866f7fb64062c616d988
parent05d428addd167d4d1d7fc3b6f4c85b4aaa5b71a7
tools: ocaml: Handle anonymous struct members of structs in libxl IDL

Julien has a patch "arm: Allow the user to specify the GIC version"
which adds an anonymous struct to libxl_domain_build_info:

    @ -480,6 +486,11 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                           ])),
                      ("invalid", None),
                      ], keyvar_init_val = "LIBXL_DOMAIN_TYPE_INVALID")),
    +
    +
    +    ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
    +                              ])),
    +
         ], dir=DIR_IN
     )

(libxl_gic_version is an enum). This is not currently supported by the
ocaml genwrap.py. Add a simple pass which handles simple anonymous
unions as top level members of a struct type, but not more deeply
nested since that would be a much more complex change and is not
currently required.

With Juliens patch applied the relevant resulting change to the .mli
is:

    --- tools/ocaml/libs/xl/_libxl_BACKUP_types.mli.in 2015-07-08 11:22:35.000000000 +0100
    +++ tools/ocaml/libs/xl/_libxl_types.mli.in 2015-07-08 12:25:56.000000000 +0100
    @@ -469,6 +477,10 @@ module Domain_build_info : sig

      type type__union = Hvm of type_hvm | Pv of type_pv | Invalid

    + type arch_arm__anon = {
    + gic_version : gic_version;
    + }
    +
      type t =
      {
      max_vcpus : int;
    @@ -510,6 +522,7 @@ module Domain_build_info : sig
      ramdisk : string option;
      device_tree : string option;
      xl_type : type__union;
    + arch_arm : arch_arm__anon;
      }
      val default : ctx -> ?xl_type:domain_type -> unit -> t
     end

The .ml differs similarly. Without Julien's patch there is no change.

gen_struct is refactored slightly to take the indent level as an
argument, since it is now used at a different level.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Julien Grall <julien.grall@citrix.com>
Cc: Dave Scott <Dave.Scott@citrix.com>
Cc: Rob Hoes <Rob.Hoes@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Rob Hoes <rob.hoes@citrix.com>
Acked-by: David Scott <dave.scott@citrix.com>
tools/ocaml/libs/xl/genwrap.py